package com.changgou.goods.feign;

import com.changgou.entity.Result;
import com.changgou.goods.pojo.Sku;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(name="goods")
public interface SkuFeign {

    /***
     * 根据spuId查询sku列表信息
     */
    @GetMapping("/sku/spu/{spuId}")
    public Result findSkuListBySpuId(@PathVariable("spuId") String spuId);

    /***
     * 根据ID查询数据
     * @param id
     * @return
     */
    @GetMapping("/sku/{id}")
    public Result<Sku> findById(@PathVariable("id") String id);

    /**
     * 扣减库存
     * @param username
     * @return
     */
    @PostMapping("/sku/decr/count")
    public Result decrCount(@RequestParam("username") String username);

    /**
     * 回滚库存
     * @param skuId
     * @param num
     */
    @PutMapping("/sku/resume/{skuId}/{num}")
    public Result resumeStockNum(@PathVariable("skuId") String skuId,@PathVariable("num") Integer num);
}
